import sys
import pyglet
import cocos
from cocos.scenes import *

class ImageLayer(cocos.layer.Layer):
	is_event_handler = True

	def __init__ (self,imageRef):
		super(ImageLayer,self).__init__()
		self.add(imageRef)
		self.done = False

#def on_mouse_pressed(self,x,y,button,modifiers):
	def on_key_press(self,key,modifiers):
		self.done = True
		print 'Key pressed !'

	def on_mouse_motion(self,x,y,dx,dy):
		print 'Mouse moved !'

	def on_mouse_press(self,x,y,button,modifier):
		print 'Mouse clicked !'
		

class ImageScene(cocos.scene.Scene):
	def __init__ (self,imageRef):
		super(ImageScene,self).__init__()
		
		layer = ImageLayer(imageRef)
		self.add(layer)

# Test
if __name__ == '__main__':
	pyglet.resource.path.append('../data/gfx')
	pyglet.resource.reindex()
	cocos.director.director.init(width=1024, height=768)
	blackScreen = cocos.scene.Scene(cocos.layer.ColorLayer(0,0,0,0))
	scene1 = ImageScene(cocos.sprite.Sprite('title.png', anchor=(0,0)))
	cocos.director.director.run(blackScreen)
	cocos.director.director.replace(FadeTRTransition(scene1))

